package com.itheima.spec.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.mapper.Mapper;
import com.itheima.goods.pojo.Spec;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public interface SpecMapper extends BaseMapper<Spec> {



    @Select("insert into tb_spec values(null,#{name},#{options},#{seq})")
     void insertSpec(Spec spec);

    @Delete("delete from tb_spec where id=#{id}")
    void deleteSpec(Integer id);


    @Select("select * from tb_spec where id=#{id}")
    List<Spec> findSpecById(Integer id);

    @Update("update tb_spec set name=#{name},options=#{options},seq=#{seq} where id=#{id}")
    void updateSpec(@Param("name") String name,
                    @Param("options") String options,
                    @Param("seq") Integer seq,
                    @Param("id") Integer id);

    @Select("select * from tb_spec where name like concat ('%',#{name},'%')")
    List<Spec> findSpecLikeName(String name);

}
